#include <iostream>
#include "majestic.h"
#include <SFML/Audio.hpp>
#define MAXSOUNDS 100
int counter;

sf::SoundBuffer stab[MAXSOUNDS];
sf::SoundBuffer buffer;
void Majestic::Sound::run()
{
}
bool Majestic::Sound::isfull()
{
			if (counter >=MAXSOUNDS) return true;
			return false;
}
Majestic::Sound::Sound()
{
    sound.SetLoop(0);
    sound.SetVolume(100);
	counter = 0;
    cout << sound.GetVolume();

}
int Majestic::Sound::queue(const char *file)
{
    if (!stab[counter].LoadFromFile(file))
    {
        return -1;
    }
	return counter++;
}
void Majestic::Sound::play(const char *file)
{
    if (!buffer.LoadFromFile(file))
    {
        return;
    }
    sound.SetBuffer(buffer);
    sound.Play();
    while(sound.GetStatus() == sf::Sound::Playing)
    {
        sf::Sleep(0.1f);
    }
}
void Majestic::Sound::play(int id)
{
    if (id>0&&id<MAXSOUNDS) sound.SetBuffer(stab[id]);
    sound.Play();
    while(sound.GetStatus() == sf::Sound::Playing)
    {
        sf::Sleep(0.1f);
    }
}
void Majestic::Sound::stop()
{
    sound.Stop();
}
void Majestic::Sound::setvolume(int volume)
{
    sound.SetVolume(volume);
}
void Majestic::Sound::clear()
{
    //for(int i=0;i<MAXSOUNDS;i++) ~stab[i];
    counter=0;
}

